#ifndef DYNAMICCURVEDISPLAYINTERFACE_H
#define DYNAMICCURVEDISPLAYINTERFACE_H

#include <QMainWindow>
#include <QtCharts/QChartGlobal>
#include <QtCharts/QChart>

#include <QSqlTableModel>
#include <QtCharts/QChartView>    // 图表视图
#include<QChartView>
#include <QtCharts/QLineSeries>   // 折线图系列
#include <QtCharts/QDateTimeAxis> // 时间轴
#include <QtCharts/QValueAxis>
#include<QMessageBox>
#include "usermysqls.h"
QT_CHARTS_USE_NAMESPACE
namespace Ui {
class DynamicCurveDisplayInterface;
}
 QT_CHARTS_USE_NAMESPACE // 启用 Qt Charts 命名空间

class DynamicCurveDisplayInterface : public QMainWindow
{

    Q_OBJECT


public:
    static DynamicCurveDisplayInterface* instance();
    explicit DynamicCurveDisplayInterface(QWidget *parent = nullptr);
    ~DynamicCurveDisplayInterface();
    bool isProcessing=false;

private:
    Ui::DynamicCurveDisplayInterface *ui;
    QSqlTableModel *model;
    QChart *chart;                   // 图表对象
    QLineSeries *seriesTemperature;  // 温度数据系列
    QDateTimeAxis *axisX;            // X轴（时间）
    QValueAxis *axisY;               // Y轴（数值）
    QLineSeries *series[5];  // 5条曲线: 温度/湿度/光照/CO2/土壤湿度
    QTimer *dataTimer;       // 数据更新定时器
    const int SHOW_SECONDS = 30;  // 显示最近30秒数据
    static int locationCount;
    QTimer *timeOutTimer;
    QPushButton * pushButtonBack;//返回按钮
private slots:

    void readyUpdateChartData();
    void updateChartDataS();
    void on_pushButtonBack_clicked();



private:

    void setupModel();
    void setupChart();
    void updateChartData();
    void QtimerDisplayCurve();


};

#endif // DYNAMICCURVEDISPLAYINTERFACE_H
